﻿using Framework.Config;
using Framework.EncryptionService.Attributes;
using Framework.FreeSqlClient.InteFace;
using Framework.RequestEntitys.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Text.Json.Serialization;

namespace Bright.NetCore.Api.Controllers
{
    [Route("api/FreeSql/[action]")]
    [ApiController]
    public class FreeSqlTestController : ControllerBase
    {
        IFreeSqlOperation FreeSql;

        ConfigHelp ConfigHelp;
        public FreeSqlTestController(IFreeSqlOperation freeSql, ConfigHelp config)
        {
            FreeSql = freeSql;
            ConfigHelp = config;
        }

        [HttpGet]
        [NonEncrypted]
        public void TestFunc()
        {
            try
            {
                Console.WriteLine(FreeSql.FreeSqlClient.Ado.ConnectionString);
                Console.WriteLine(ConfigHelp.Logging);
                FreeSql.FreeSqlClient.Select<TestModel>().ToSql();
                FreeSql.FreeSqlClient.Select<TestModel>().ToList();

            }
            catch (Exception e)
            {
                Console.WriteLine($"构造函数注入时出现位置异常，异常信息：{e}");
            }
        }
    }
}
